package com.dekarrin.scraton;

public class Author {

	private String[] names;
	
	private Gender gender;
	
	public Author(String name, Gender gender) {
		names = name.split(" ");
		this.gender = gender;
	}
	
	public Gender getGender() {
		return gender;
	}
	
	public String getFullName() {
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < names.length - 1; i++) {
			builder.append(names[i]);
			builder.append(" ");
		}
		builder.append(names[names.length - 1]);
		return builder.toString();
	}
	
	public String getFirstInitialLastName() {
		String name = getInitial(0) + " " + getLastName();
		return name;
	}
	
	public String getFirstNameLastInitial() {
		String name = getFirstName() + " " + getInitial(names.length - 1);
		return name;
	}
	
	public String getInitials() {
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < names.length; i++) {
			builder.append(getInitial(i));
		}
		return builder.toString();
	}
	
	public String getShortName() {
		String name = getFirstName() + " " + getLastName();
		return name;
	}
	
	public String getFirstName() {
		return names[0];
	}
	
	public String getLastName() {
		return names[names.length - 1];
	}
	
	private String getInitial(int n) {
		String initial = names[n].substring(0, 1);
		return initial.toUpperCase();
	}

}